﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Xinnos.Lca.Yacht.Analyzer.View
{
    /// <summary>
    /// CommonDialog.xaml에 대한 상호 작용 논리
    /// </summary>
    public partial class CommonDialog : Window
    {
        public CommonDialog(UIElement element)
        {
            InitializeComponent();
            gridMain.Children.Add(element);
            switch (element.GetType().Name)
            {
                case "WorkBreakdownStructurePanel":
                    (element as WorkBreakdownStructurePanel).Confirmed += new EventHandler(OnConfirmed);
                    break;
                case "WorkBreakdownStructureGroupPanel":
                    (element as WorkBreakdownStructureGroupPanel).Confirmed += new EventHandler(OnConfirmed);
                    break;
            }
        }

        private void OnConfirmed(object sender, EventArgs e)
        {
            this.DialogResult = true;
        }

        private void OnClosed(object sender, EventArgs e)
        {
            MasterViewModel _master = MasterViewModel.GetInstance();
            UIElement _child = gridMain.Children[0];
            switch (_child.GetType().Name)
            {
                case "WorkBreakdownStructureTabPanel":
                    _master.Structure = false;
                    break;
                case "EnvironmentalProfilesPanel":
                    _master.Profile = false;
                    break;
                case "EnvironmentalProfilesGraphPanel":
                    _master.Pie = false;
                    break;
                case "ComponentsPanel":
                    _master.Component = false;
                    break;
                case "ObjectRatePanel":
                    _master.Assessment = false;
                    break;
                case "AssessmentGraphPanel":
                    _master.Graph = false;
                    break;
            }
        }
    }
}
